/*
 * @Author: fengxx
 * @Date: 2025-10-12 20:03:57
 * @LastEditors: fengxx
 * @LastEditTime: 2025-10-27 11:00:50
 */
import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import * as Icons from '@element-plus/icons'
import MyMenuItem from './components/MyMenuItem.vue'

import App from './App.vue'
import router from './router'
import './mock'

const app = createApp(App)
const pinia = createPinia()

app.use(ElementPlus, {
  locale: zhCn,
})
app.use(pinia)
app.use(router)
app.component('MyMenuItem', MyMenuItem)
// 注册全局组件
Object.keys(Icons).forEach((key) => {
  app.component(key, Icons[key as keyof typeof Icons])
})

// (全局注册自定义指令)使 v-highlight 在所有组件中都可⽤
app.directive('highlight', {
  mounted: (el, binding, vnode) => {
    if (binding.arg === 'foo' && binding.modifiers.bar) {
      el.classList.add(binding.value)
    } else {
      el.classList.add('is-highlight')
    }

    console.log(binding, vnode)
  },
})

app.mount('#app')
